import query from '@dfeidao/atom-nodejs/db/query';
import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { productid, systemid } from '../../atom/config';

interface Message {
	no: string;
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:d:\a飞道考核\kh\src\imple-records\zj-000005\s002,action_id:' + action_id);

	const q = query(action_id, session_id, systemid);
	q.prepare('inspect_project',
		['check_item_no', 'plan_item_name', 'note_taker_name', 'inspect_post_name', 'recording_time'],
		{ productid, record_no: message.no }, 200, 1, [], []);

	const res = await q.exec();

	log('Service end path:d:\a飞道考核\kh\src\imple-records\zj-000005\s002,action_id:' + action_id);
	return {
		data: res[0]
	};
}
